// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------

import request from '@/utils/request'
import fileRequest from '@/utils/file'

/**
 * 数据tree数据
 * @param pram
 * @param biztype
 */
export function treeCategroy(pram,biztype) {
  const data = {
    //type: pram.type,
    //status: pram.status,
    name: pram.name
  }
  let url = ''
  if (biztype === 3) url = `/dep/getDepTree`
  if (biztype === 2) url = `/phoneData/getPhoneTree`
  if (biztype === 1) url = `/data/getPerTree`
  if (biztype === 4) url = `/getFileTypeList`
  return request({
    url: url,
    method: 'GET',
    params: data //get用params
  })
}

export function getTree(params){
  return request({
    url:'/getFileTypeList',
    method:'GET',
    params
  })
}

export function detail(id){
  return request({
    url:'/detailFileType',
    method:'GET',
    params:{id}
  })
}

export function save(data){
  return request({
    url:'/insertFileType',
    method:'POST',
    data
  })
}

export function updateStatus(id,status){
  return request({
    url:'/statusFileType',
    method:'GET',
    params:{id,status}
  })
}

export function treeCategroyFile(pram,pid) {
  const data = {
    //type: pram.type,
    //status: pram.status,
    name: pram.name,
    pid: pid
  }
  let url = `/getFileTypeList`
  return request({
    url: url,
    method: 'GET',
    params: data //get用params
  })
}

/**
 * 删除单位
 * @param pram
 */
export function deleteCategroyForDepartment(pram) {
  const data = {
    id: pram.id
  }
  return request({
    url: '/dep/deleteDep',
    method: 'GET',
    params: data //get用params
  })
}

/**
 * 修改 显示关闭状态
 * @param pram
 * @param biztype
 */
export function categroyUpdateStatus(pram,biztype) {
  const data = {
    id: pram.id,
    status: pram.status
  }
  let url = ''
  if (biztype === 3) url = `/dep/updateDepStatus`
  if (biztype === 2) url = `/phoneData/updatePhoneStatus`
  if (biztype === 1) url = `/data/updateCategoryStatus`
  return request({
    url: url,
    method: 'GET',
    params: data //get用params
  })
}

/**
 * 新增分类
 * @param pram
 * @param biztype
 */
export function addCategroy(pram,biztype) {
  let url = ''
  let data = {}
  if(biztype === 3){
    url = '/dep/insertDep'
    data = {
      name: pram.name,
      shortName: pram.shortName,
      pid: pram.pid,
      sort: pram.sort,
      status: pram.status,
      isCards: pram.isCards,
      level: pram.level,
      personName: pram.personName,
      id: pram.id
    }
  }else{
    if(biztype == 2) url = '/phoneData/insertAndUpdatePhone'
    if(biztype == 1) url = '/data/insertAndUpdateCategory'

    data = {
      //extra: pram.extra,
      name: pram.name,
      pid: pram.pid,
      sort: pram.sort,
      status: pram.status,
      id: pram.id
      //type: pram.type,
      //url: pram.url
    }
  }

  return request({
    url: url,
    method: 'POST',
    data: data
  })
}

/**
 * 人员category数据
 */
export function categoryList() {
  return request({
    url: `/person/getDropList`,
    method: 'GET',
  })
}

/**
 * 人员基本数据下拉项
 */
export function personOption() {
  return request({
    url: `/person/getPersonTitleList`,
    method: 'GET',
  })
}

/**
 * 人员军事训练数据
 */
export function categoryTrainList() {
  return request({
    url: `/train/getDropList`,
    method: 'GET',
  })
}

/**
 * 人员电子设备category数据
 */
export function categoryElcList() {
  return request({
    url: `/elc/getDropList`,
    method: 'GET',
  })
}

/**
 * 人员社交媒体账号category数据
 */
export function categoryElcAccountList() {
  return request({
    url: `/media/getDropList`,
    method: 'GET',
  })
}

export function categoryMessageList() {
  return request({
    url: `/message/getMessageTypeList`,
    method: 'GET',
  })
}

/**
 * 事件category数据
 */
export function categoryIncList() {
  return request({
    url: `/inc/getDropList`,
    method: 'GET',
  })
}

/**
 * 型号category数据
 */
export function categoryModelTypeList() {
  return request({
    url: `/type/getDropList`,
    method: 'GET',
  })
}

export function categoryCarList() {
  return request({
    url: `/car/getDropList`,
    method: 'GET',
  })
}

export function categoryEquipList() {
  return request({
    url: `/equip/getDropList`,
    method: 'GET',
  })
}

/**
 * 福利费category数据
 */
export function categoryEnjoyList() {
  return request({
    url: `/enjoy/enjoyTypeList`,
    method: 'GET',
  })
}

/**
 * 试验category数据
 */
export function categoryTestsList() {
  return request({
    url: `/tests/getDropList`,
    method: 'GET',
  })
}

/**
 * 人员电子设备category数据
 */
export function categoryPointList() {
  return request({
    url: `/point/getDropList`,
    method: 'GET',
  })
}


/**
 * 分类详情
 * @param pram
 */
export function infoCategroy(pram) {
  const data = {
    id: pram.id
  }
  return request({
    url: '/admin/category/info',
    method: 'GET',
    params: data
  })
}

/**
 * 删除分类
 * @param pram
 */
export function deleteCategroy(pram) {
  const data = {
    id: pram.id
  }
  return request({
    url: '/admin/category/delete',
    method: 'GET',
    params: data
  })
}

/**
 * 分类列表
 * @param pram
 */
export function listCategroy(pram) {
  const data = {
    limit: pram.limit,
    name: pram.name,
    page: pram.page,
    pid: pram.pid,
    status: pram.status,
    //type: pram.type

  }
  return request({
    url: '/admin/category/list',
    method: 'GET',
    params: data
  })
}

/**
 * 根据id集合查询对应分类列表
 * @param pram
 */
export function categroyByIds(pram) {
  const data = {
    ids: pram.ids
  }
  return request({
    url: '/admin/category/list/ids',
    method: 'GET',
    params: data
  })
}



/**
 * 文章详情
 * @param pram
 */
export function articleInfoApi(params) {
  return request({
    url: `/admin/article/info`,
    method: 'GET',
    params
  })
}

/**
 * 导出
 * @param data
 * @returns {*}
 */
export function exportRoster(data) {
  return fileRequest({
    url: '/excel/testFailureExcel',
    method: 'POST',
    data: data,
    responseType:'blob'
  })
}

/**
 * 文件导入
 * @param data
 */
export function doImport(data) {
  return request({
    url: '/import/importTestFailure',
    method: 'POST',
    data
  })
}

/**
 * 文件导入
 * @param data
 */
export function computerExcelApi(data) {
  return request({
    url: '/import/computerExcel',
    method: 'POST',
    data
  })
}
/**
 * 文件导入
 * @param data
 */
export function researchComputerExcelApi(data) {
  return request({
    url: '/import/researchComputerExcel',
    method: 'POST',
    data
  })
}
/**
 * 文件导入
 * @param data
 */
export function standComputerExcelApi(data) {
  return request({
    url: '/import/standComputerExcel',
    method: 'POST',
    data
  })
}
/**
 * 文件导入
 * @param data
 */
export function hardDiskComputerExcelApi(data) {
  return request({
    url: '/import/hardDiskComputerExcel',
    method: 'POST',
    data
  })
}
/**
 * 文件导入
 * @param data
 */
export function elseComputerExcelApi(data) {
  return request({
    url: '/import/elseComputerExcel',
    method: 'POST',
    data
  })
}

/**
 * 文件导入
 * @param data
 */
export function OfficeComputerExcelApi(data) {
  return request({
    url: '/import/OfficeComputerExcel',
    method: 'POST',
    data
  })
}
